<template>
  <div>
    <!-- 面包屑导航区域 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>系统管理</el-breadcrumb-item>
      <el-breadcrumb-item>用户管理</el-breadcrumb-item>
    </el-breadcrumb>

    <!-- 卡片视图区域 -->
    <el-card style="margin-bottom: 8px;">
      <!-- 搜索与添加区域 -->
      <el-row :gutter="30">
        <el-col :span="7.3">
          <el-form :model="ssUsers" ref="ssRef" label-width="100px">
            <!-- :rules="editFormRules" -->
            <!-- :model绑定数据模型  :rules验证规则  :ref绑定当前页传输数据-->
            <el-form-item label="用户所在科室" prop="deptname">
              <el-select v-model="ssUsers.deptid" placeholder="请选择所在科室">
                <el-option
                  v-for="(item,index) in deptList"
                  :key="index"
                  :label="item.deptname"
                  :value="item.id"
                ></el-option>
                <!-- <el-option label="2-儿科" value="2"></el-option> -->
              </el-select>
            </el-form-item>

            <el-form-item label="选择用户类别" prop="usetype">
              <el-select v-model="ssUsers.usetype" placeholder="请选择用户类别">
                <el-option
                  v-for="(item,index) in HisSytem"
                  :key="index"
                  :label="item.his_Name"
                  :value="item.his_Id"
                ></el-option>
                <!-- <el-option label="6-财务管理" value="6"></el-option> -->
              </el-select>
            </el-form-item>

            <el-form-item label="选择医生职称" prop="constantName" v-if="ssUsers.usetype==3">
              <el-select v-model="ssUsers.doctitleid" placeholder="请选择医生职称">
                <el-option
                  v-for="(item,index) in doctitleList"
                  :key="index"
                  :label="item.constantname"
                  :value="item.id"
                ></el-option>
                <!-- <el-option label="82-副主任医师" value="82"></el-option> -->
              </el-select>
            </el-form-item>

            <el-form-item label="输入查询内容">
              <el-input placeholder="请输入登录名或真实姓名" v-model="ssUsers.realname" clearable>
                <el-button slot="append" icon="el-icon-search" @click="ssUserList()"></el-button>
              </el-input>
            </el-form-item>
          </el-form>
        </el-col>

        <el-col :span="12">
          <el-button type="success" @click="addWindow = true">添加用户</el-button>
          <!-- <el-button type="primary" @click="addssWindow = true">批量添加</el-button> -->
          <el-button type="danger" @click="deleteIdListButton">批量删除</el-button>
          <!-- @click="addDialogVisible = true" -->
        </el-col>
      </el-row>
    </el-card>

    <el-card>
      <!-- 用户列表区域 -->
      <el-table :data="userlist" border stripe ref="idlistRef" @selection-change="handleIdList">
        <el-table-column type="selection" width="40"></el-table-column>
        <el-table-column label="编号" type="index" prop="data"></el-table-column>
        <el-table-column label="登录名" prop="username"></el-table-column>
        <el-table-column label="真实姓名" prop="realname"></el-table-column>
        <el-table-column label="所在科室" prop="department.deptname"></el-table-column>
        <el-table-column label="用户类别" prop="hisSytem.his_Name"></el-table-column>
        <el-table-column label="医生职称" prop="constantItem.constantname"></el-table-column>

        <el-table-column label="操作" width="200px" align="center">
          <template slot-scope="scope">
            <!-- 修改按钮 -->
            <el-button
              type="primary"
              icon="el-icon-edit"
              size="mini"
              @click="showEditUser(scope.row.id)"
            >编辑</el-button>
            <!-- @click="showEditDialog(scope.row.id)" -->

            <!-- 删除按钮 -->
            <el-button
              icon="el-icon-delete"
              type="danger"
              size="mini"
              style="margin-left: 18px;"
              @click="removeUserById(scope.row.id)"
            >删除</el-button>
            <!-- @click="removeUserById(scope.row.id)" -->
          </template>
        </el-table-column>
      </el-table>

      <!-- 批量选择 -->
      <!-- <div style="margin-top: 20px" v-if="deleteWindow == true">
        <el-button @click="idList(userlist)">全选</el-button>
        <el-button @click="idList()" :disabled="idlist.length == 0">取消选择</el-button>
        <el-button @click="deleteList()">确认删除</el-button>
      </div>-->
    </el-card>

    <!-- 添加用户的对话框 -->
    <el-dialog title="添加用户" width="40%" :visible.sync="addWindow" @close="addClose">
      <!-- :visible.sync="addDialogVisible"  @close="addDialogClosed" -->

      <!-- 内容主体区域 -->
      <el-form :model="addForm" ref="addFormRef" label-width="100px" :rules="addFormRules">
        <!-- :rules="addFormRules" -->
        <!-- :model绑定数据模型  :rules验证规则  :ref绑定当前页传输数据-->
        <el-form-item label="登录名" prop="username">
          <el-input v-model="addForm.username"></el-input>
        </el-form-item>

        <el-form-item label="密码" prop="password">
          <el-input v-model="addForm.password"></el-input>
        </el-form-item>

        <el-form-item label="真实姓名" prop="realname">
          <el-input v-model="addForm.realname"></el-input>
        </el-form-item>

        <el-form-item label="用户所在科室" prop="deptid">
          <el-select v-model="addForm.deptid" placeholder="请选择所在科室">
            <el-option
              v-for="(item,index) in deptList"
              :key="index"
              :label="item.deptname"
              :value="item.id"
            ></el-option>
            <!-- <el-option label="2-儿科" value="2"></el-option> -->
          </el-select>
        </el-form-item>

        <el-form-item label="选择用户类别" prop="usetype">
          <el-select v-model="addForm.usetype" placeholder="请选择用户类别">
            <el-option
              v-for="(item,index) in HisSytem"
              :key="index"
              :label="item.his_Name"
              :value="item.his_Id"
            ></el-option>
            <!-- <el-option label="6-财务管理" value="6"></el-option> -->
          </el-select>
        </el-form-item>
        <el-form-item label="选择医生职称" prop="doctitleid" v-if="addForm.usetype==3">
          <el-select v-model="addForm.doctitleid" placeholder="请选择医生职称">
            <el-option
              v-for="(item,index) in doctitleList"
              :key="index"
              :label="item.constantname"
              :value="item.id"
            ></el-option>
            <!-- <el-option label="82-副主任医师" value="82"></el-option> -->
          </el-select>
        </el-form-item>
        <el-form-item label="是否参与排班" prop="isscheduling">
          <el-switch
            v-model="addForm.isscheduling"
            active-color="#13ce66"
            active-value="是"
            inactive-value="否"
            active-text="  参与排班  "
            inactive-text="  不参与排班  "
          ></el-switch>
        </el-form-item>
      </el-form>
      <!-- 底部区域 -->
      <span slot="footer" class="dialog-footer">
        <el-button @click="addWindow = false;addClose()">取 消</el-button>
        <el-button type="primary" @click="addUser">确 定</el-button>
      </span>
    </el-dialog>

    <!-- 批量添加上传文件 -->
    <el-dialog title="添加用户" width="50%" :visible.sync="addssWindow" @close="addClose">
      <!-- @close="addClose" -->

      <!-- <el-upload
        class="filter-item"
        name="excelFile"
        :action="uploadUrl()"
        :on-error="uploadFalse"
        :on-success="uploadSuccess"
        :before-upload="beforeAvatarUpload"
        :limit="1"
         accept=".xlsx,.xls"
        :show-file-list="false"
        :file-list="fileList">
         <el-button  style="margin-left: 10px;" icon="el-icon-edit" type="primary">批量上架</el-button>
      </el-upload>-->

      <!-- 底部区域 -->
      <span slot="footer" class="dialog-footer">
        <el-button>取 消</el-button>
        <!--  @click="addWindow = false;addClose()" -->
        <el-button type="primary">确 定</el-button>
        <!-- @click="addUser" -->
      </span>
    </el-dialog>

    <!-- 修改用户的对话框 -->
    <el-dialog title="修改用户" width="40%" :visible.sync="editWindow" @close="editClose">
      <!-- :visible.sync="editDialogVisible"  @close="editDialogClosed" -->
      <!-- 内容主体区域 -->
      <el-form :model="editForm" ref="editFormRef" label-width="100px" :rules="editFormRules">
        <!-- :rules="editFormRules" -->
        <!-- :model绑定数据模型  :rules验证规则  :ref绑定当前页传输数据-->
        <el-form-item label="登录名" prop="username">
          <el-input v-model="editForm.username"></el-input>
        </el-form-item>
        <el-form-item label="密码" prop="password">
          <el-input v-model="editForm.password"></el-input>
        </el-form-item>
        <el-form-item label="真实姓名" prop="realname">
          <el-input v-model="editForm.realname"></el-input>
        </el-form-item>
        <el-form-item label="用户所在科室" prop="deptname">
          <el-select v-model="editForm.deptid" placeholder="请选择所在科室">
            <el-option
              v-for="(item,index) in deptList"
              :key="index"
              :label="item.deptname"
              :value="item.id"
            ></el-option>
            <!-- <el-option label="2-儿科" value="2"></el-option> -->
          </el-select>
        </el-form-item>

        <el-form-item label="选择用户类别" prop="usetype">
          <el-select v-model="editForm.usetype" placeholder="请选择用户类别">
            <el-option
              v-for="(item,index) in HisSytem"
              :key="index"
              :label="item.his_Name"
              :value="item.his_Id"
            ></el-option>
            <!-- <el-option label="6-财务管理" value="6"></el-option> -->
          </el-select>
        </el-form-item>

        <el-form-item label="选择医生职称" prop="constantName" v-if="editForm.usetype==3">
          <el-select v-model="editForm.doctitleid" placeholder="请选择医生职称">
            <el-option
              v-for="(item,index) in doctitleList"
              :key="index"
              :label="item.constantname"
              :value="item.id"
            ></el-option>
            <!-- <el-option label="82-副主任医师" value="82"></el-option> -->
          </el-select>
        </el-form-item>

        <el-form-item label="是否参与排班" prop="constantName">
          <el-switch
            v-model="editForm.isscheduling"
            active-color="#13ce66"
            active-value="是"
            inactive-value="否"
            active-text="  参与排班  "
            inactive-text="  不参与排班  "
          ></el-switch>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="editWindow = false;editClose()">取 消</el-button>
        <el-button type="primary" @click="editUser">确 定</el-button>
      </span>
    </el-dialog>

    <div class="block">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="queryInfo.pagenum"
        :page-sizes="page"
        :page-size="queryInfo.pagesize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      // 获取用户列表的参数对象
      queryInfo: {
        // 当前的页数
        pagenum: 1,
        // 当前每页显示多少条数据
        pagesize: 5
      },

      page:[
        2,5,10,20
      ],
      
      idlist:[],
      //删除对号
      isidlist:false,
      
      //分页记录总数
      total: 0,
      // 用户集合
      userlist: [
          // {username:'chuwang', realname:'如风',deptname:'综合科',usetype:'1-管理员',    constantname:'81-主任医师'},
          // {username:'123',     realname:'乐乐',deptname:'眼科',  usetype:'4-医技医生',  constantname:'84-住院医师'},
          // {username:'321',     realname:'李娜',deptname:'放射科',usetype:'3-门诊医生',  constantname:'83-主治医师'},
          // {username:'c222',    realname:'赵帅',deptname:'泌尿科',usetype:'3-门诊医生',  constantname:'83-主治医师'},
          // {username:'qweqwg',  realname:'田野',deptname:'妇产科',usetype:'3-门诊医生',  constantname:'83-主治医师'},
          // {username:'chdfreng',realname:'刘丽',deptname:'中医科',usetype:'4-医技医生',  constantname:'83-主治医师'}, 
          // {username:'chong',   realname:'吉娜',deptname:'医药科',usetype:'5-药房操作员',constantname:'84-住院医师'},
          // {username:'chugong', realname:'门昊',deptname:'门诊科',usetype:'3-门诊医生',  constantname:'83-主治医师'},
          // {username:'qulzhong',realname:'景威',deptname:'急诊科',usetype:'3-门诊医生',  constantname:'83-主治医师'}
      ],

      //科室目录
      deptList:[],
      //用户类别
      HisSytem:[],
      //常数项集合
      constantTypeList:[],
      //医生职称
      doctitleList:[],


    //条件搜索用户对象
      ssUsers: {
        username: '',
        realname: '',
        deptid: '',
        usetype: '',
        doctitleid: '',

        // 当前的页数
        pagenum: 1,
        // 当前每页显示多少条数据
        pagesize: 5
      },

      // 添加用户的表单数据（再添加中绑定头中用(:visible.sync) 这个属性来绑定要弹出弹窗的属性）
      addWindow: false,
      // 批量添加上传文件
      addssWindow: false,

      //添加用户对象
      addForm: {
        username: '',
        password: '',
        realname: '',
        deptid: '',
        usetype: '',
        doctitleid: '',
        isscheduling: '否',
      },

      // 添加表单的验证规则对象
      addFormRules: {
        username: [
          { required: true, message: '请输入用户名', trigger: 'blur' },
          {
            min: 3,
            max: 10,
            message: '用户名的长度在3~10个字符之间',
            trigger: 'blur'
          }
        ],

        password: [
          { required: true, message: '请输入密码', trigger: 'blur' },
          {
            min: 6,
            max: 15,
            message: '用户名的长度在6~15个字符之间',
            trigger: 'blur'
          }
        ],

        realname: [
          { required: true, message: '请输入用户名', trigger: 'blur' },
          {
            min: 3,
            max: 10,
            message: '用户名的长度在3~10个字符之间',
            trigger: 'blur'
          }
        ],
        
      },

      // 控制修改用户对话框的显示与隐藏
      editWindow: false,
      // 查询到的用户信息对象
      editForm: {
        username: '',
        password: '',
        realname: '',
        deptid: '',
        usetype: '',
        doctitleid: '',
        isscheduling: '',
        registleid:'',
        delmark:'',
      },
      // 修改表单的验证规则对象
      editFormRules: {
        username: [
          { required: true, message: '请输入用户名', trigger: 'blur' },
          {
            min: 3,
            max: 10,
            message: '用户名的长度在3~10个字符之间',
            trigger: 'blur'
          }
        ],

        password: [
          { required: true, message: '请输入密码', trigger: 'blur' },
          {
            min: 6,
            max: 15,
            message: '用户名的长度在6~15个字符之间',
            trigger: 'blur'
          }
        ],

        realname: [
          { required: true, message: '请输入用户名', trigger: 'blur' },
          {
            min: 3,
            max: 10,
            message: '用户名的长度在3~10个字符之间',
            trigger: 'blur'
          }
        ],
      },


      // // 控制分配角色对话框的显示与隐藏
      // setRoleDialogVisible: false,
      // // 需要被分配角色的用户信息
      // userInfo: {},
      // // 所有角色的数据列表
      // rolesList: [],
      // // 已选中的角色Id值
      // selectedRoleId: '',


      // 删除前查询到的用户信息对象
      removeForm: {
        id:''
      },

    }
  },
  created() {
    this.getUserList()
    this.getDeptmentName()
    this.getHisSytem() 
    this.getconstantTypeList()
  },
  methods: {

    ////////////////////////// 遍 历 事 件 /////////////////////////////

    // 获取到userlist
    async getUserList() {
      const { data: res } = await this.$http.post("user/his_user",this.queryInfo)

      console.log("-------****-------");
      console.log(res);
      console.log("------------------");
      
      if(res.meta.status!==200){
        return this.$message.error('加载失败:'+res.meta.msg);
      }
      // this.$message.success('加载成功');

      this.userlist = res.data
      this.total = res.count
      //获取返回数据是否赋值成功
      console.log("-------****-------");
      console.log(this.total);
      console.log("-------****-------");
    },

    // 获取到Deptment科室列表
    async getDeptmentName() {
      const { data: res } = await this.$http.get("departmentController/getlist")

      console.log("------****-------");
      console.log(res);
      console.log("-----------------");
      
      if(res.meta.status!==200){
        return this.$message.error('加载失败:'+res.meta.msg);
      }
      // this.$message.success('加载成功');

      this.deptList = res.data
    },

    // 获取到HisSytem系统分类
    async getHisSytem() {
      const { data: res } = await this.$http.get("hissytemcontroller/selectHis")

      console.log("-----------------");
      console.log(res);
      console.log("-----------------");
      
      if(res.meta.status!==200){
        return this.$message.error('加载失败:'+res.meta.msg);
      }
      // this.$message.success('加载成功');

      this.HisSytem = res.data
    },

     // 根据ConstantType获取到ConstantItem的职称项
    async getconstantTypeList() {
      const { data: res } = await this.$http.get("constanttypecontroller/getlist")

      console.log("---------==cc--------");
      console.log(res);
      console.log("---------==cc--------");
      
      if(res.meta.status!==200){
        return this.$message.error('加载失败:'+res.meta.msg);
      }
      // this.$message.success('加载成功');

      this.constantTypeList = res.data
      this.doctitleList = this.constantTypeList[3].constantItemsList
    },
    
    ////////////////////////// 分 页 设 置 /////////////////////////////


    // 监听 pagesize 改变的事件
    handleSizeChange(newSize) {

      console.log(`每页 ${newSize} 条`)
      // this.queryInfo.pagesize = newSize

      if(this.ssUsers == '' || this.ssUsers.realname==''){
        this.queryInfo.pagesize = newSize
        this.getUserList()
      }
      else{
        this.ssUsers.pagesize = newSize
        this.ssUserList()
      }
      
    },
    // 监听 页码值 改变的事件
    handleCurrentChange(newPage) {
      
      console.log('+++++------+++++')
      console.log(`当前页: ${newPage}`)
      // this.queryInfo.pagenum = newPage
      console.log(this.ssUsers.realname)
      console.log('+++++++++++++++')

      
      if(this.ssUsers =='' || this.ssUsers.realname==''){
        this.queryInfo.pagenum = newPage
        this.getUserList()

      }
      else{
        this.ssUsers.pagenum = newPage
        this.ssUserList()
      }
    },
    // // 监听 switch 开关状态的改变
    // async userStateChanged(userinfo) {
    //   console.log(userinfo)
    //   const { data: res } = await this.$http.put(
    //     `users/${userinfo.id}/state/${userinfo.mg_state}`
    //   )
    //   if (res.meta.status !== 200) {
    //     userinfo.mg_state = !userinfo.mg_state
    //     return this.$message.error('更新用户状态失败！')
    //   }
    //   this.$message.success('更新用户状态成功！')
    // },


    ////////////////////////////////////////////////////////////////////
    ////////////////////////// 点 击 事 件 /////////////////////////////
    ///////////////////////////////////////////////////////////////////


    ///////////////////////////批量删除
    // sel(row){
    //   return row.id
    // },

    handleIdList(val) {
       //val 为选中数据的集合
      this.idlist = val;
      console.log('-------====------')
      // console.log(val)
      console.log(this.idlist)
      console.log('-------====------')
    },

    //批量删除按钮触发事件
    async deleteIdListButton(){
      //批量删除对应的用户信息
      // console.log(this.idlist)

      for(let item of this.idlist) {

        this.removeForm.id = item.id
        const { data: res } = await this.$http.post('user/removeUser',this.removeForm)
        console.log("+++++++++++++++=")
        console.log(res)
        res.meta.status

      }
      this.getUserList()

 

// item：定义的每一条的变量

 

// response.data.result：要循环的数组
      
      // this.idlist.forEach((item) => {
        
      //   this.removeForm.id = item.id
      //   const { data: res } = await this.$http.post('user/removeUser',this.removeForm)
      //   console.log("+++++++++++++++=")
      //   console.log(res)
      //   res.meta.status
  
      // }),

      // this.getUserList()
    },


    //点击搜索事件
    ssUserList() {
      this.$refs.ssRef.validate(async valid => {
        if (!valid) return

        console.log("-----------------");
        console.log(this.ssUsers);
        console.log("-----------------");

        const { data: res } = await 
        this.$http.post("user/selectBySS",this.ssUsers
          // {
          //   ssUser:this.ssUsers,
          //   queryInfo:this.queryInfo,
          // }
        )

        console.log("-----------------");
        console.log(res);
        console.log("-----------------");
        
        if(res.meta.status!==200){
          return this.$message.error('加载失败:'+res.meta.msg);
        }
        // this.$message.success('加载成功');

        
        this.userlist = res.data
        this.total = res.count

        console.log("-------****-------");
        console.log(this.total);
        console.log("-------****-------");
        
      })
    },

    //////////////////////////点击添加部分 /////////////////////////////  

    //添加页面关闭时重置表单  监听添加用户对话框的关闭事件
    addClose() {
      this.$refs.addFormRef.resetFields()
    },

    // 点击按钮，添加新用户
    addUser() {
      this.$refs.addFormRef.validate(async valid => {
        if (!valid) return
        // 可以发起添加用户的网络请求
        const { data: res } = await this.$http.post('user/addUser',this.addForm)

        if (res.meta.status !== 200) {
          this.$message.error('添加用户失败！')
        }

        this.$message.success('添加用户成功！')
        // 隐藏添加用户的对话框
        this.addWindow = false
        // 重置表单
        this.addClose()
        // 重新获取用户列表数据
        this.getUserList()
        
      })
    },

    //////////////////////////点击修改展示 /////////////////////////////  

    // 展示编辑用户的对话框
    async showEditUser(id) {
      console.log(id)
      // this.selectedRoleId = id;
      this.editForm.id = id;
      // console.log(this.selectedRoleId)
      //根据id来查询用户的信息
      const { data: res } = await this.$http.post('user/showEditUser',this.editForm)

      console.log(res)

      if (res.meta.status !== 200) {
        return this.$message.error('查询用户信息失败！')
      }

      //将获取到的数据保存到editForm中
      this.editForm = res.data
      //显示窗口
      this.editWindow = true
    },

    //////////////////////////点击修改部分 /////////////////////////////  

    // 监听修改用户对话框的关闭事件
    editClose() {
      this.$refs.editFormRef.resetFields()
    },
    // 修改用户信息并提交
    editUser() {
      this.$refs.editFormRef.validate(async valid => {
        if (!valid) return
        // 发起修改用户信息的数据请求
        const { data: res } = await this.$http.post('user/editUser',this.editForm)

        if (res.meta.status !== 200) {
          return this.$message.error('更新用户信息失败！')
        }

        // 关闭对话框
        this.editWindow = false
        // 刷新数据列表
        this.getUserList()
        // 提示修改成功
        this.$message.success('更新用户信息成功！')
      })
    },

    //////////////////////////点击删除部分 /////////////////////////////

    // 根据Id删除对应的用户信息
    
    async removeUserById(id) {
      
      // 弹框询问用户是否删除数据
      const confirmResult = await this.$confirm(
        '此操作将永久删除该用户, 是否继续?',
        '提示',
        {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }
      ).catch(err => err)

      // 如果用户确认删除，则返回值为字符串 confirm
      // 如果用户取消了删除，则返回值为字符串 cancel

      console.log('---------------')
      console.log(confirmResult)
      console.log('---------------')
      
      if (confirmResult !== 'confirm') {
        return this.$message.info('已取消删除')
      }

      this.removeForm.id = id

      const { data: res } = await this.$http.post('user/removeUser',this.removeForm)
      console.log("+++++++++++++++=")
      console.log(res)

      if (res.meta.status !== 200) {
        return this.$message.error('删除用户失败！')
      }

      this.$message.success('删除用户成功！')
      this.getUserList()
    },


    

    //////////////////////////确认提示弹窗 /////////////////////////////

    // // 确认提示对话框
    // open() {
    //     this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
    //       confirmButtonText: '确定',
    //       cancelButtonText: '取消',
    //       type: 'warning'
    //     }).then(() => {
    //       this.$message({
    //         type: 'success',
    //         message: '删除成功!'
    //       });
    //     }).catch(() => {
    //       this.$message({
    //         type: 'info',
    //         message: '已取消删除'
    //       });          
    //     });
    // },


    ////////////////////////////////上传excel并批量添加//////////////////////////////////////
    uploadSuccess(response, file, fileList) {
      console.log(response)
      if (response.code==200) {
        this.$message({
          message: response.message,
          type: 'success'
        });
      } else {
        this.$message({
          message: response.message,
          type: 'error'
        });
      }
    },
    uploadFalse(response, file, fileList) {
      this.$message({
          message: '文件上传失败！',
          type: 'error'
        });
    },
    // 上传前对文件的大小的判断
    beforeAvatarUpload(file) {
      const extension = file.name.split(".")[1] === "xls";
      const extension2 = file.name.split(".")[1] === "xlsx";
      const isLt2M = file.size / 1024 / 1024 < 10;
         if (!extension && !extension2) {
           this.$message({
            message: '上传模板只能是 xls、xlsx格式!',
            type: 'error'
           });
          }
          if (!isLt2M) {
           console.log("上传模板大小不能超过 10MB!");
           this.$message({
            message: '上传模板大小不能超过 10MB!',
            type: 'error'
          });
         }
        return extension || extension2 || extension3 || (extension4 && isLt2M);
    },
    uploadUrl: function() {
      return (
        process.env.VUE_APP_BASE_API+'/good/ExcelInsertGoodinStore'+
        "?businessid=" +
        this.$store.getters.id
      );
    },

   


  }
}
</script>

<style lang="less" scoped>
</style>